//
//  Tile.h
//  TabulaImaginarius2
//
//  Created by TA2 on 4/29/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DrawingLayer.h"
#import "Players.h"
#import "Token.h"
#import "LoadedImages.h"

@class NetworkController;
@class NetworkProtocol;
@class DrawProtocol;

@interface Tile : NSObject <NSCoding> {
	CGPoint				point;
	int					currentLayerIndex;
	NSMutableDictionary *layersForPlayers;
	NSString			*imageName;
	CGLayerRef			currentImage;
	CGLayerRef			drawingBuffer;
	DrawingPath			*currentPath;
	NSObject			*currentPathLock;
	NSObject			*currentImageLock;
	NSMutableArray		*tokenStack;
	BOOL				imageIsModified;
}

@property (nonatomic, retain) NSString *imageName;
@property (nonatomic) CGPoint point;
@property (nonatomic) int currentLayerIndex;
@property (nonatomic, retain) NSMutableArray *tokenStack;
@property (nonatomic) CGLayerRef drawingBuffer;

- (id)init;
- (void)bufferImage;
- (void)modifyBufferedImage:(UIImage *)image withImagePath:(NSString *)path;
- (void)saveAndReleaseBufferedImage;
- (CGLayerRef)getImage;
- (NSString *)getBackgroundPath;
- (void)clearVisiblePaths;
- (void)addPathToLayer:(DrawingPath *)path forLayer:(int)index forPlayer:(Player *)player;
- (NSArray *)getLayersForPlayer:(Player *)player;
- (void)addPointToCurrentPath:(CGPoint)newPoint forLayer:(int)index withLineWidth:(float)lineWidth withColor:(UIColor *)color withColorTexturePath:(NSString *)colorTexturePath;
- (void)deleteCurrentPath;
- (DrawingPath *)getCurrentPath;
- (void)finalizeCurrentPath;
- (void)encodeWithCoder:(NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;

@end
